using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    public partial class vwAllocationsWVenuesComponent
    {
		//
		// TODO: Add constructor logic here
		//

        /// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public List<vwAllocationsWVenues> SelectAllWPlacementTypeId(int placementTypeId, string sortExpression)
        {
            List<vwAllocationsWVenues> listvwAllocationsWVenues = new List<vwAllocationsWVenues>();
            PlacementManager.DAL.vwAllocationsWVenues_DAL o = new PlacementManager.DAL.vwAllocationsWVenues_DAL();

            DataSet ds = o.SelectAllWPlacementTypeId(placementTypeId);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listvwAllocationsWVenues.Add(new vwAllocationsWVenues((int)row["UserId"], (string)row["UserName"], (string)row["FirstName"], (string)row["LastName"], (string)row["IdNumber"], (bool)row["IsActive"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"], (bool)row["Expr1"], (string)row["VenueName"], (int)row["VenueId"], (int)row["AllocationId"], (int)row["PlacementTypeId"], (int)row["CompletionStatusId"], (DateTime)row["DateCreated"]));
            }

            if (sortExpression == string.Empty)
            {
                sortExpression = "LastName desc";
            }

            listvwAllocationsWVenues.Sort(new vwAllocationsWVenuesComparer(sortExpression));
            return listvwAllocationsWVenues;
        }
	}
}
